using System;
using Shatkotha.WPF.Global.Bases;

namespace Shatkotha.WPF.Global.Common.Controls.Dialog
{
    public abstract class ADialogContentPresenter : APresenter, IDialogContentPresenter
    {
        public ADialogContentPresenter(IView view)
            :base(view)
        {
            
        }
        #region IDialogContentPresenter Members

        public event EventHandler<GenericEventArgs<DialogResult>> DialogResultEvent;
        public event EventHandler<GenericEventArgs<DialogResult>> DialogClosed;
        
        protected virtual void OnDialogClosed(DialogResult e)
        {            
            if(DialogClosed != null)
                DialogClosed(this, new GenericEventArgs<DialogResult>(e));
        }

        public virtual void OnDialogResultEvent(DialogResult dialogResult)
        {
            if (DialogResultEvent != null)
            {
                DialogResultEvent(this, new GenericEventArgs<DialogResult>(dialogResult));
            }
        }

        public virtual bool OnClosing(DialogResult dialogResult)
        {
            IsVisible = false;
            OnDialogClosed(dialogResult);
            return true;
        }
        
        #endregion

        #region IDialogContentPresenter Members

        public bool IsVisible { get; set; }

        public virtual void OnShowing()
        {
            IsVisible = true;
        }

        public virtual void OnActivated()
        {
            
        }

        #endregion
    }
}